const webSocket = require('ws')

const ws = new webSocket.Server({
    port:3000
})

let count =0

ws.on('connection',(socket)=>{
    console.log('建立连接');
    socket.on('message',(data)=>{
        // console.log(data.toString());
        socket.send('欢迎访问')
        setInterval(()=>{
            count++
            socket.send(count)
        },2000)
    })

})

